<template>
	<view class="content">
		<Shoplist :title="title" :list="shops"></Shoplist>
	</view>
</template>

<script>
	import Shoplist from '../../components/ShopList.vue'
	//获取全局变量
	const {
		globalData
	} = getApp()
	/*数据库*/
	const db = wx.cloud.database();
	export default {
		data() {
			return {
				shops: [
			
				],
				title:''
			}
		},
		onLoad() {
			this.getshops()
			this.title=globalData.categoryName
		},
		components: {
			Shoplist
		},

		methods: {
			getshops() {
		
			

				db.collection('favorList').where({
						category_id: globalData.classfiyId,
						place: globalData.address
					})
					.get({
						success:(res)=>{
							this.shops=this.parseShops(res.data)
						}
					})

			},
			parseShops(data){
				data.forEach((item,key)=>{
					if(item.image_path === null){
						item.image_path = 'mdata/img/404.jpg';
					}
				})
				return data;
			}
			
		}
	}
</script>

<style>

</style>
